/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package merlion.scm.rmpm.entity;

import java.io.Serializable;
import java.sql.Timestamp;
import java.util.Date;
import java.util.Random;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

/**
 *
 * @author Hong
 */
@Entity
public class SupplierContactRecord implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;
    private String name;
    private String jobTitle;
    private String phone;
    private String email;
    private Boolean executive;
    private Timestamp hiddenId;

    public SupplierContactRecord() {
        name = "";
        jobTitle = "";
        phone = "";
        email = "";
        executive = false;
        
        Random rand = new Random();
        long seed = new Date().getTime() + (long)rand.nextInt(10000);
        hiddenId = new Timestamp(seed);
    }
    
    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getJobTitle() {
        return jobTitle;
    }

    public void setJobTitle(String jobTitle) {
        this.jobTitle = jobTitle;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public Boolean getExecutive() {
        return executive;
    }

    public void setExecutive(Boolean executive) {
        this.executive = executive;
    }

    public Timestamp getHiddenId() {
        return hiddenId;
    }

    public void setHiddenId(Timestamp hiddenId) {
        this.hiddenId = hiddenId;
    }
    
    @Override
    public SupplierContactRecord clone(){
        SupplierContactRecord s = new SupplierContactRecord();
        s.setEmail(email);
        s.setExecutive(executive);
        s.setJobTitle(jobTitle);
        s.setName(name);
        s.setPhone(phone);
        s.setHiddenId(hiddenId);
        
        return s;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        if (!(object instanceof SupplierContactRecord)) {
            return false;
        }
        SupplierContactRecord other = (SupplierContactRecord) object;
        
        // Compare hiddenId
        if(!this.hiddenId.equals(other.hiddenId))
            return false;
        return true;
    }

    @Override
    public String toString() {
        return "merlion.scm.rmpm.entity.SupplierContactRecord[ id=" + id + " ]";
    }
}